﻿using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MongoDB.Bson;
using Colorful.Database;
using Colorful.Apps.ERP.Models;

namespace Colorful.Apps.ERP
{
    #region DbContext
    public partial class DbContext : Colorful.CMS.Core.DbContext
    {
        private IMongoDatabase _db;

        #region 初始化
        public DbContext(string server, string username, string password, string dbName)
            : base(server, username, password, dbName)
        {
            _db = this.Database;
        }
        public DbContext(string connStr, string dbName,string collectionPrefix = "")
            :base(connStr, dbName, collectionPrefix)
        {
            _db = this.Database;
        }
        #endregion

        /// <summary>
        /// 客户表
        /// </summary>
        public IMongoCollection<Client> Clients
        {
            get
            {
                return base.GetCollection<Client>("Client");
            }
        }
        /// <summary>
        /// 产品表
        /// </summary>
        public IMongoCollection<Product> Products
        {
            get
            {
                return base.GetCollection<Product>("Product");
            }
        }
        /// <summary>
        /// 展示产品表
        /// </summary>
        public IMongoCollection<ProductShow> ShowProducts
        {
            get
            {
                return base.GetCollection<ProductShow>("ShowProducts");
            }
        }
        /// <summary>
        /// 订单表
        /// </summary>
        public IMongoCollection<Order> Orders
        {
            get
            {
                return base.GetCollection<Order>("Order");
            }
        }
        /// <summary>
        /// 费用支出
        /// </summary>
        public IMongoCollection<Expend> Expends
        {
            get
            {
                return base.GetCollection<Expend>("Expends");
            }
        }
        /// <summary>
        /// 费用支出
        /// </summary>
        public IMongoCollection<Purchase> Purchases
        {
            get
            {
                return base.GetCollection<Purchase>("Purchase");
            }
        }
        /// <summary>
        /// 库存表
        /// </summary>
        public IMongoCollection<Stock> Stocks
        {
            get
            {
                return base.GetCollection<Stock>("Stock");
            }
        }
        /// <summary>
        /// 供货商
        /// </summary>
        public IMongoCollection<Vender> Venders
        {
            get
            {
                return base.GetCollection<Vender>("Vender");
            }
        }
    }
    #endregion
}
